package com.syn.synold4s.activity;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewTreeObserver;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.evrencoskun.tableview.TableView;
import com.gaoyi.basemodule.apiresult.ApiResultData;
import com.gaoyi.basemodule.baseUtil.DensityUtil;
import com.gaoyi.basemodule.baseUtil.GsonUtil;
import com.google.gson.reflect.TypeToken;
import com.syn.synold4s.R;
import com.syn.synold4s.adapter.TableViewAdapter;
import com.syn.synold4s.bean.Cell;
import com.syn.synold4s.bean.ColumnHeader;
import com.syn.synold4s.bean.RowHeader;
import com.syn.synold4s.bean.dto.GasMonitoringDto;
import com.syn.synold4s.bean.dto.GassDto;
import com.syn.synold4s.bean.dto.MainDto;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TestActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_test);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });


//        HRecyclerView hRecyclerView = findViewById(R.id.id_hrecyclerview);
//        hRecyclerView.setHeaderListData(new String[]{});
//
//        GasAdapter adapter = new GasAdapter(this, new ArrayList<>(), R.layout.item_gas);
//
//        hRecyclerView.setAdapter(adapter);
        TableView tableView = findViewById(R.id.table_view);
        View root = findViewById(R.id.fl_root);
        root.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                root.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                tableView.getLayoutParams().height = root.getHeight();
            }
        });
        tableView.getCellRecyclerView().setNestedScrollingEnabled(true);

        tableView.setRowHeaderWidth(DensityUtil.dp2px(80));
        TableViewAdapter adapter = new TableViewAdapter();
        tableView.setAdapter(adapter);

// 设置数据
//        List<ColumnHeader> columnHeaders = Arrays.asList(
//                new ColumnHeader("Column 1"),
//                new ColumnHeader("Column 2"),
//                new ColumnHeader("Column 3"),
//                new ColumnHeader("Column 4"),
//                new ColumnHeader("Column 5")
//        );
//
//        List<RowHeader> rowHeaders = Arrays.asList(
//                new RowHeader("Row 1"),
//                new RowHeader("Row 2"),
//                new RowHeader("Row 3"),
//                new RowHeader("Row 4"),
//                new RowHeader("Row 5")
//        );
//
//        List<List<Cell>> cells = Arrays.asList(
//                Arrays.asList(new Cell("1-1"), new Cell("1-2"), new Cell("1-3"), new Cell("1-4"), new Cell("1-5")),
//                Arrays.asList(new Cell("2-1"), new Cell("2-2"), new Cell("2-3"), new Cell("2-4"), new Cell("2-5")),
//                Arrays.asList(new Cell("3-1"), new Cell("3-2"), new Cell("3-3"), new Cell("3-4"), new Cell("3-5")),
//                Arrays.asList(new Cell("4-1"), new Cell("3-2"), new Cell("3-3"), new Cell("3-4"), new Cell("3-5")),
//                Arrays.asList(new Cell("3-1"), new Cell("3-2"), new Cell("3-3"), new Cell("3-4"), new Cell("3-5"))
//        );

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                String result = "{\n" +
                        "    \"status\": 2000,\n" +
                        "    \"message\": \"查詢成功\",\n" +
                        "    \"data\": {\n" +
                        "        \"envtal\": [\n" +
                        "            {\n" +
                        "                \"deviceCode\": \"50073195\",\n" +
                        "                \"deviceName\": \"50073195\",\n" +
                        "                \"code\": null,\n" +
                        "                \"name\": null,\n" +
                        "                \"val\": null,\n" +
                        "                \"portalAt\": \"2024-12-20 16:39:53\",\n" +
                        "                \"baseTypeId\": 0,\n" +
                        "                \"gass\": [\n" +
                        "                    {\n" +
                        "                        \"code\": \"TMP\",\n" +
                        "                        \"name\": \"溫度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 05:25:11\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"HR\",\n" +
                        "                        \"name\": \"濕度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 19:56:31\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"O2\",\n" +
                        "                        \"name\": \"氧氣\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 23:37:45\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"CO\",\n" +
                        "                        \"name\": \"一氧化碳\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 06:51:14\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"H2S\",\n" +
                        "                        \"name\": \"硫化氫\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 22:38:27\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"LEL\",\n" +
                        "                        \"name\": \"可燃氣體\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 05:22:09\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FL\",\n" +
                        "                        \"name\": \"風力\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 03:41:08\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"WL\",\n" +
                        "                        \"name\": \"水位\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 02:26:48\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM10\",\n" +
                        "                        \"name\": \"pm10\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 13:51:42\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FS\",\n" +
                        "                        \"name\": \"風速\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 02:28:30\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM25\",\n" +
                        "                        \"name\": \"pm2.5\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 04:08:01\"\n" +
                        "                    }\n" +
                        "                ],\n" +
                        "                \"tops\": null,\n" +
                        "                \"wls\": null\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"deviceCode\": \"8248\",\n" +
                        "                \"deviceName\": \"8248瑤安氣體\",\n" +
                        "                \"code\": null,\n" +
                        "                \"name\": null,\n" +
                        "                \"val\": null,\n" +
                        "                \"portalAt\": \"2024-12-20 16:39:53\",\n" +
                        "                \"baseTypeId\": 0,\n" +
                        "                \"gass\": [\n" +
                        "                    {\n" +
                        "                        \"code\": \"TMP\",\n" +
                        "                        \"name\": \"溫度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 06:44:05\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"HR\",\n" +
                        "                        \"name\": \"濕度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 02:44:42\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"O2\",\n" +
                        "                        \"name\": \"氧氣\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 07:00:10\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"CO\",\n" +
                        "                        \"name\": \"一氧化碳\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 16:15:09\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"H2S\",\n" +
                        "                        \"name\": \"硫化氫\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 17:54:13\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"LEL\",\n" +
                        "                        \"name\": \"可燃氣體\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 09:41:18\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FL\",\n" +
                        "                        \"name\": \"風力\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 14:27:15\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"WL\",\n" +
                        "                        \"name\": \"水位\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 01:58:43\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM10\",\n" +
                        "                        \"name\": \"pm10\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 13:26:03\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FS\",\n" +
                        "                        \"name\": \"風速\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 21:38:00\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM25\",\n" +
                        "                        \"name\": \"pm2.5\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 08:56:35\"\n" +
                        "                    }\n" +
                        "                ],\n" +
                        "                \"tops\": null,\n" +
                        "                \"wls\": null\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"deviceCode\": \"40276874\",\n" +
                        "                \"deviceName\": \"40276874\",\n" +
                        "                \"code\": null,\n" +
                        "                \"name\": null,\n" +
                        "                \"val\": null,\n" +
                        "                \"portalAt\": \"2024-12-20 16:39:53\",\n" +
                        "                \"baseTypeId\": 0,\n" +
                        "                \"gass\": [\n" +
                        "                    {\n" +
                        "                        \"code\": \"TMP\",\n" +
                        "                        \"name\": \"溫度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 03:15:54\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"HR\",\n" +
                        "                        \"name\": \"濕度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 15:25:47\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"O2\",\n" +
                        "                        \"name\": \"氧氣\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 17:07:05\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"CO\",\n" +
                        "                        \"name\": \"一氧化碳\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 07:26:31\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"H2S\",\n" +
                        "                        \"name\": \"硫化氫\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 02:58:03\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"LEL\",\n" +
                        "                        \"name\": \"可燃氣體\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 17:50:36\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FL\",\n" +
                        "                        \"name\": \"風力\",\n" +
                        "                        \"val\": \"0.0\",\n" +
                        "                        \"portalAt\": \"2024-11-21 17:08:49\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"WL\",\n" +
                        "                        \"name\": \"水位\",\n" +
                        "                        \"val\": \"-0.125\",\n" +
                        "                        \"portalAt\": \"2024-11-21 17:08:49\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM10\",\n" +
                        "                        \"name\": \"pm10\",\n" +
                        "                        \"val\": \"1\",\n" +
                        "                        \"portalAt\": \"2024-11-21 17:08:49\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FS\",\n" +
                        "                        \"name\": \"風速\",\n" +
                        "                        \"val\": \"0.0\",\n" +
                        "                        \"portalAt\": \"2024-11-21 17:08:49\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM25\",\n" +
                        "                        \"name\": \"pm2.5\",\n" +
                        "                        \"val\": \"0.3\",\n" +
                        "                        \"portalAt\": \"2024-11-21 17:08:49\"\n" +
                        "                    }\n" +
                        "                ],\n" +
                        "                \"tops\": null,\n" +
                        "                \"wls\": null\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"deviceCode\": \"11111\",\n" +
                        "                \"deviceName\": \"987654321\",\n" +
                        "                \"code\": null,\n" +
                        "                \"name\": null,\n" +
                        "                \"val\": null,\n" +
                        "                \"portalAt\": \"2024-12-20 16:39:53\",\n" +
                        "                \"baseTypeId\": 0,\n" +
                        "                \"gass\": [\n" +
                        "                    {\n" +
                        "                        \"code\": \"TMP\",\n" +
                        "                        \"name\": \"溫度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 18:47:20\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"HR\",\n" +
                        "                        \"name\": \"濕度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 15:57:22\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"O2\",\n" +
                        "                        \"name\": \"氧氣\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 10:40:38\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"CO\",\n" +
                        "                        \"name\": \"一氧化碳\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 06:22:39\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"H2S\",\n" +
                        "                        \"name\": \"硫化氫\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 05:58:18\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"LEL\",\n" +
                        "                        \"name\": \"可燃氣體\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 19:33:19\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FL\",\n" +
                        "                        \"name\": \"風力\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 19:08:24\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"WL\",\n" +
                        "                        \"name\": \"水位\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 03:44:57\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM10\",\n" +
                        "                        \"name\": \"pm10\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 11:44:21\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FS\",\n" +
                        "                        \"name\": \"風速\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 05:26:05\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM25\",\n" +
                        "                        \"name\": \"pm2.5\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 19:03:24\"\n" +
                        "                    }\n" +
                        "                ],\n" +
                        "                \"tops\": null,\n" +
                        "                \"wls\": null\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"deviceCode\": \"8246\",\n" +
                        "                \"deviceName\": \"8246瑤安氣體\",\n" +
                        "                \"code\": null,\n" +
                        "                \"name\": null,\n" +
                        "                \"val\": null,\n" +
                        "                \"portalAt\": \"2024-12-20 16:39:53\",\n" +
                        "                \"baseTypeId\": 0,\n" +
                        "                \"gass\": [\n" +
                        "                    {\n" +
                        "                        \"code\": \"TMP\",\n" +
                        "                        \"name\": \"溫度\",\n" +
                        "                        \"val\": \"0\",\n" +
                        "                        \"portalAt\": \"2024-12-12 08:56:31\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"HR\",\n" +
                        "                        \"name\": \"濕度\",\n" +
                        "                        \"val\": \"0\",\n" +
                        "                        \"portalAt\": \"2024-12-12 08:56:31\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"O2\",\n" +
                        "                        \"name\": \"氧氣\",\n" +
                        "                        \"val\": \"0\",\n" +
                        "                        \"portalAt\": \"2024-12-12 08:56:31\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"CO\",\n" +
                        "                        \"name\": \"一氧化碳\",\n" +
                        "                        \"val\": \"0\",\n" +
                        "                        \"portalAt\": \"2024-12-12 08:56:31\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"H2S\",\n" +
                        "                        \"name\": \"硫化氫\",\n" +
                        "                        \"val\": \"0\",\n" +
                        "                        \"portalAt\": \"2024-12-12 08:56:31\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"LEL\",\n" +
                        "                        \"name\": \"可燃氣體\",\n" +
                        "                        \"val\": \"0\",\n" +
                        "                        \"portalAt\": \"2024-12-12 08:56:31\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FL\",\n" +
                        "                        \"name\": \"風力\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 12:47:42\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"WL\",\n" +
                        "                        \"name\": \"水位\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 21:49:56\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM10\",\n" +
                        "                        \"name\": \"pm10\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 04:24:44\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FS\",\n" +
                        "                        \"name\": \"風速\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 18:50:54\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM25\",\n" +
                        "                        \"name\": \"pm2.5\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 20:21:54\"\n" +
                        "                    }\n" +
                        "                ],\n" +
                        "                \"tops\": null,\n" +
                        "                \"wls\": null\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"deviceCode\": \"8249\",\n" +
                        "                \"deviceName\": \"8249瑤安氣體\",\n" +
                        "                \"code\": null,\n" +
                        "                \"name\": null,\n" +
                        "                \"val\": null,\n" +
                        "                \"portalAt\": \"2024-12-20 16:39:53\",\n" +
                        "                \"baseTypeId\": 0,\n" +
                        "                \"gass\": [\n" +
                        "                    {\n" +
                        "                        \"code\": \"TMP\",\n" +
                        "                        \"name\": \"溫度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 18:10:40\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"HR\",\n" +
                        "                        \"name\": \"濕度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 16:35:01\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"O2\",\n" +
                        "                        \"name\": \"氧氣\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 17:15:17\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"CO\",\n" +
                        "                        \"name\": \"一氧化碳\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 02:06:20\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"H2S\",\n" +
                        "                        \"name\": \"硫化氫\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 07:32:15\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"LEL\",\n" +
                        "                        \"name\": \"可燃氣體\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 05:26:58\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FL\",\n" +
                        "                        \"name\": \"風力\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 23:39:44\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"WL\",\n" +
                        "                        \"name\": \"水位\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 08:57:25\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM10\",\n" +
                        "                        \"name\": \"pm10\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 06:50:36\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FS\",\n" +
                        "                        \"name\": \"風速\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 12:15:14\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM25\",\n" +
                        "                        \"name\": \"pm2.5\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 10:37:36\"\n" +
                        "                    }\n" +
                        "                ],\n" +
                        "                \"tops\": null,\n" +
                        "                \"wls\": null\n" +
                        "            },\n" +
                        "            {\n" +
                        "                \"deviceCode\": \"001\",\n" +
                        "                \"deviceName\": \"123456789\",\n" +
                        "                \"code\": null,\n" +
                        "                \"name\": null,\n" +
                        "                \"val\": null,\n" +
                        "                \"portalAt\": \"2024-12-20 16:39:53\",\n" +
                        "                \"baseTypeId\": 0,\n" +
                        "                \"gass\": [\n" +
                        "                    {\n" +
                        "                        \"code\": \"TMP\",\n" +
                        "                        \"name\": \"溫度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 01:45:44\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"HR\",\n" +
                        "                        \"name\": \"濕度\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 21:40:33\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"O2\",\n" +
                        "                        \"name\": \"氧氣\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 02:55:24\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"CO\",\n" +
                        "                        \"name\": \"一氧化碳\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 18:22:19\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"H2S\",\n" +
                        "                        \"name\": \"硫化氫\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 20:27:26\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"LEL\",\n" +
                        "                        \"name\": \"可燃氣體\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 10:57:15\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FL\",\n" +
                        "                        \"name\": \"風力\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 11:24:23\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"WL\",\n" +
                        "                        \"name\": \"水位\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 12:52:08\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM10\",\n" +
                        "                        \"name\": \"pm10\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 15:41:35\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"FS\",\n" +
                        "                        \"name\": \"風速\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-21 11:01:22\"\n" +
                        "                    },\n" +
                        "                    {\n" +
                        "                        \"code\": \"PM25\",\n" +
                        "                        \"name\": \"pm2.5\",\n" +
                        "                        \"val\": \"\",\n" +
                        "                        \"portalAt\": \"2024-12-20 18:56:02\"\n" +
                        "                    }\n" +
                        "                ],\n" +
                        "                \"tops\": null,\n" +
                        "                \"wls\": null\n" +
                        "            }\n" +
                        "        ]\n" +
                        "    }\n" +
                        "}";
                ApiResultData<MainDto> apiResultData = (ApiResultData<MainDto>) GsonUtil.getInstance().fromJson(result, new TypeToken<ApiResultData<MainDto>>() {
                }.getType());
                List<GasMonitoringDto> envtal = apiResultData.getData().getEnvtal();
                List<List<GassDto>> cellContent = new ArrayList<>();
                List<GassDto> gass = envtal.get(0).getGass();
                List<String> columTitle = new ArrayList<>();
                List<String> rowTitle = new ArrayList<>();
                for (int i = 0; i < gass.size(); i++) {
                    columTitle.add(gass.get(i).getName());
                }
                for (int i = 0; i < envtal.size(); i++) {
                    rowTitle.add(envtal.get(i).getDeviceName());
                    cellContent.add(envtal.get(i).getGass());
                }
                adapter.setAllItems(columTitle, rowTitle, cellContent);
            }
        }, 1000);

    }

}